package com.yuanxiao.listener;

import com.yuanxiao.pojo.Order;
import com.yuanxiao.service.OrderService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
@RocketMQMessageListener(topic = "buy_order", consumerGroup = "order-mq-group")
public class OrderConsumer implements RocketMQListener<Order> {
    @Autowired
    private OrderService orderService;

    @Override
    public void onMessage(Order order) {
        orderService.saveOrder(order);
    }
}
